<h1>CoordTransform</h1>

<p>CoordTransform is used to specify two-dimensional coordinate transforms, 
allowing an object to be scaled, rotated or moved without changing the original 
definition of how the object is drawn. A two-dimensional transform is defined 
using a 3x3 matrix and the new values for a pair of coordinates (x,y) are 
calculated using the following matrix multiplication:</p>

<img src="transform.gif">

<p>Different transformations such as scaling, rotation, shearing and translation 
can be performed using the above matrix multiplication. More complex 
transformations can be defined by performing successive matrix multiplications 
in a process known as compositing. This allows a complex transformations to 
performed on an object.</p>

<p>A CoordTransform contains a 3x3 array for defining the transformations. 
However when it is encoded the matrix is reduced to a 2x3 array. Transforms are
encoded with following set attributes:</p>

<table>

<tr>
<th>Field</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top">hasScaling</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>If true then the structure contains scaling information.</td>
</tr>

<tr>
<td nowrap valign="top">scalingSize</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">5</td>
<td>Optional. The number of bits in the scaling fields.</td>
</tr>

<tr>
<td nowrap valign="top">scaleX</td>
<td nowrap valign="top">Fixed-point (16.16)</td>
<td nowrap valign="top" align="right">&lt;scalingSize&gt;</td>
<td>Optional. The value to scale the shape in the x direction combined with the 
cosine component of any rotation.</td>
</tr>

<tr>
<td nowrap valign="top">scaleY</td>
<td nowrap valign="top">Fixed-point (16.16)</td>
<td nowrap valign="top" align="right">&lt;scalingSize&gt;</td>
<td>Optional. The value to scale the shape in the x direction combined with the 
cosine component of any rotation.</td>
</tr>

<tr>
<td nowrap valign="top">hasRotation</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>If true then the structure contains rotation information.</td>
</tr>

<tr>
<td nowrap valign="top">rotationSize</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">5</td>
<td>Optional. The number of bits in the rotation fields.</td>
</tr>

<tr>
<td nowrap valign="top"><a name="FSCoordTransform_2">rotate0</a></td>
<td nowrap valign="top">Fixed-point (16.16)</td>
<td nowrap valign="top" align="right">&lt;rotationSize&gt;</td>
<td>Optional. The sine component of any rotation applied to the shape.</td>
</tr>

<tr>
<td nowrap valign="top"><a name="FSCoordTransform_3">rotate1</a></td>
<td nowrap valign="top">Fixed-point (16.16)</td>
<td nowrap valign="top" align="right">&lt;rotationSize&gt;</td>
<td>Optional. The negative sine component of any rotation applied to the shape.</td>
</tr>

<tr>
<td nowrap valign="top">translationSize</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">5</td>
<td>The number of bits in the translation fields.</td>
</tr>

<tr>
<td nowrap valign="top">translateX</td>
<td nowrap valign="top">signed int</td>
<td nowrap valign="top" align="right">&lt;translationSize&gt;</td>
<td>The x-coordinate of any translation applied to the shape.</td>
</tr>

<tr>
<td nowrap valign="top">translateY</td>
<td nowrap valign="top">signed int</td>
<td nowrap valign="top" align="right">&lt;translationSize&gt;</td>
<td>The y-coordinate of any translation applied to the shape.</td>
</tr>

</table>

The optional fields allow coordinate transforms to be efficiently encoded. Most
transforms simply place an object at a given point on the screen so the components
used to specify roatation and scaling can be omitted.

The fixed point (16.16) format for the rotation and scaling components is 
compressed with the integer part truncated to remove and leading zeroes. The 
16 bits of the fractional part are always encoded to ensure the position of the 
fixed point is preserved.

<h2>History</h2>

<p>CoordTransform represents the Matrix data structure from the Macromedia Flash 
(SWF) File Format Specification. It was introduced in Flash 1.</p>
